CREATE TABLE [dbo].[LicenseMaster]
(
[LicenseMasterKey] [uniqueidentifier] NOT NULL,
[LicenseKey] [uniqueidentifier] NOT NULL,
[LicenseOrganizationKey] [uniqueidentifier] NOT NULL,
[NamedLicenseCount] [int] NOT NULL CONSTRAINT [DF_LicenseMaster_NamedLicenseCount] DEFAULT ((0)),
[UnnamedLicenseCount] [int] NOT NULL CONSTRAINT [DF_LicenseMaster_UnnamedLicenseCount] DEFAULT ((0)),
[Checksum] [nvarchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_LicenseMaster_Checksum] DEFAULT ((0)),
[EffectiveDate] [datetime] NOT NULL,
[ExpirationDate] [datetime] NULL,
[CreatedByUserKey] [uniqueidentifier] NOT NULL,
[CreatedOn] [datetime] NOT NULL,
[UpdatedByUserKey] [uniqueidentifier] NOT NULL,
[UpdatedOn] [datetime] NOT NULL,
[MarkedForDeleteOn] [datetime] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[LicenseMaster] ADD CONSTRAINT [PK_LicenseMaster] PRIMARY KEY CLUSTERED ([LicenseMasterKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_LicenseMaster_CreatedByUserKey] ON [dbo].[LicenseMaster] ([CreatedByUserKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_LicenseMaster_LicenseKey] ON [dbo].[LicenseMaster] ([LicenseKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_LicenseMaster_LicenseOrganizationKey] ON [dbo].[LicenseMaster] ([LicenseOrganizationKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_LicenseMaster_UpdatedByUserKey] ON [dbo].[LicenseMaster] ([UpdatedByUserKey]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[LicenseMaster] ADD CONSTRAINT [FK_LicenseMaster_License] FOREIGN KEY ([LicenseKey]) REFERENCES [dbo].[License] ([LicenseKey])
GO
ALTER TABLE [dbo].[LicenseMaster] ADD CONSTRAINT [FK_LicenseMaster_LicenseOrganization] FOREIGN KEY ([LicenseOrganizationKey]) REFERENCES [dbo].[LicenseOrganization] ([LicenseOrganizationKey])
GO
ALTER TABLE [dbo].[LicenseMaster] ADD CONSTRAINT [FK_LicenseMaster_UserMain_CreatedBy] FOREIGN KEY ([CreatedByUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO
ALTER TABLE [dbo].[LicenseMaster] ADD CONSTRAINT [FK_LicenseMaster_UserMain_UpdatedBy] FOREIGN KEY ([UpdatedByUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO